/*功能描述：
*属性：抽屉标题和状态
*1：提供打开方法openDrawer
*2：提供关闭方法closeDrawer
*3：提供关闭以及重置其内部表单字段的方法cleanDrawe
*
*/
export default{
	data(){
		return{
			title:'',
			isOpen:false,
			optype:''
		}
	},
	methods:{
		openDrawer(title) {
			this.title = title;
			this.isOpen=true;
        },
        closeDrawer() {
			this.title='';
            this.isOpen=false;
        },
		cleanDrawer(drawerForm){
			this.title='';
			this.isOpen=false;
			this.$refs[drawerForm].resetFields();
		},
		addDrawer(formRef,title){
			this.optype='A';
			this.cleanDrawer(formRef);
			this.openDrawer(title);
		},
		updateDrawer(formRef,title){
			this.optype='U';
			this.cleanDrawer(formRef);
			this.openDrawer(title);
		},
		optionAction(refName){
			if(this.optype=="A"){
				this.addOperation(refName);
			}else if(this.optype=="U"){
				this.updateOperation(refName);
			}else{
				window.vm.$Message.error("操作有误！");
			}
		}
	}
}
